-- ==============================================
-- Key Mappings
-- ==============================================
vim.g.mapleader = " "  -- Set leader key to Space

local keymap = vim.api.nvim_set_keymap

-- ==============================================
-- Normal Mode Mappings
-- ==============================================
-- Clear search highlights
keymap('n', '<Leader>nh', ':nohls<CR>', { noremap = true, silent = true })

-- Move to the first character of the line
keymap('n', '<C-h>', '^', { noremap = true, silent = true })

-- Move to the end of the line
keymap('n', '<C-l>', '$', { noremap = true, silent = true })

-- Insert a new line below
keymap('n', '<C-n>', 'i<CR><Esc>', { noremap = true, silent = true })

-- Open a new line below in insert mode
keymap('n', '<C-j>', 'o<Esc>', { noremap = true, silent = true })

-- Open a new line above in insert mode
keymap('n', '<C-k>', 'O<Esc>', { noremap = true, silent = true })

-- ==============================================
-- Visual Mode Mappings
-- ==============================================
-- Select to the first character of the line
keymap('x', '<C-h>', '^', { noremap = true, silent = true })

-- Select to the end of the line
keymap('x', '<C-l>', '$', { noremap = true, silent = true })

-- ==============================================
-- Insert Mode Mappings
-- ==============================================
-- Exit insert mode with 'jk'
keymap('i', 'jk', '<Esc>', { noremap = true, silent = true })

-- ==============================================
-- End
-- ==============================================
